/**
 * Explorer Main Class
 */

/**
 * @author Rukaister
 *
 */

package Main;

import Utilities.*;

public class Main {

	/**
	 * @param args[0] : file path 
	 * @param args[1] : 0 is quick search, 1 is full search
	 * @param args[2] : algorithm to use, 0 is KMP, 1 is Boyer-Moore
	 * @param args[3] : words to search
	 * @throws Throwable 
	 */
	public static void main(String[] args) throws Throwable {
		try {
			//if the arguments are wrong, exit
			if (args.length<4) throw(new Throwable("Wrong arguments exception."));
			
			/* 
			//Get begin time
			long time = System.currentTimeMillis();
			*/

			//Search files
			SearchResults Results = FileManagement.Search(args[0], Integer.parseInt(args[1]), Integer.parseInt(args[2]), args[3]);
			if (Results==null) throw(new Throwable("Something is wrong with the arguments."));
			
			/*
			//Get end time for test purpose *REMOVE THIS IN FINAL*
			time = System.currentTimeMillis() - time;
			System.out.println(time + " miliseconds.");
			*/
			
			//Output search results
			Results.ThrowJSONSearchResults();
	
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
